# Hyperledger fabric deployment file.
#
# Example usage: kubectl create -f <this_file>
---
apiVersion: v1
kind: Pod
metadata:
  name: pte{{ item }}{{ pteenv }}{{ chaincode | replace('_', '') }}
  labels:
    k8s-app: pte{{ item }}{{ pteenv }}{{ chaincode | replace('_', '') }}
spec:
  imagePullSecrets:
    - name: regcred
  restartPolicy: OnFailure
  volumes:
    - name: task-pv-storage
      persistentVolumeClaim:
        claimName: fabriccerts
    - name: {{ item }}{{ pteenv }}{{ chaincode | replace('_', '') }}
      configMap:
        name: {{ item }}{{ pteenv }}{{ chaincode | replace('_', '') }}
  containers:
    - name: pte{{ item }}{{ pteenv }}{{ chaincode | replace('_', '') }}
      image: {{ pte.repo.url }}fabric-pte:{{ pte.repo.tag }}
      imagePullPolicy: Always
      env:
        - { name: "TESTCASE", value: "{{ testcase }}" }
        - { name: "TESTCASE_QUERY", value: "{{ testcase_query }}" }
        - { name: "CHAINCODE", value: "{{ chaincode }}" }
      volumeMounts:
        - { mountPath: "/var/hyperledger/fabric/artifacts", name: "task-pv-storage" }
        - { mountPath: "/var/hyperledger/fabric/testcase", name: "{{ item }}{{ pteenv }}{{ chaincode | replace('_', '') }}" }
      command: ["bash"]
      args: ["-c","cp /var/hyperledger/fabric/testcase/{{ item }}.sh . && chmod +x {{ item }}.sh && ./{{ item }}.sh"]
